<extend name="./base" />
<block name="body">
    <table class="table">
      <caption>需求列表</caption>
      <thead>
        <tr>         
          <th>学生姓名</th>
          <th>联系方式</th>
          <th>年级</th>
          <th>课程</th>
          <th>时间</th>
          <th>地址</th>
          <th>状态</th>
          <th>审核</th>
        </tr>
      </thead>
      <tbody>
      <?php $lesson_arr = array(1=>"一年级",2=>"二年级",3=>"三年级",4=>"四年级",5=>"五年级",6=>"六年级",7=>"初一",8=>"初二",9=>"初三",10=>"高一",11=>"高二",12=>"高三",);?>
      <?php  if($data){?>
      <foreach name="data" item="vo">
        <tr>
          <td>{$vo.name}</td>
          <td>{$vo.cellphone}</td>
          <td>{$lesson_arr[$vo[grade]]}</td>
          <td>{$vo.lesson}</td>
          <td>{$vo.time}</td>
          <td>{$vo.address}</td>
          <!--td><a href="__ROOT__/index.php/Admin/Requirement/detail/id/{$vo.id}">详情</a></td-->
          <td>
                <if condition="($vo.verify eq 0) "> 待审核  </if>
                <if condition="($vo.verify eq 1) "> 已审核  </if>
                <if condition="($vo.verify eq 2) "> 审核失败  </if>
          </td>
          
          <td>
              <select class="cl_status" data-id="{$vo.id}" >
                  <option value="0" <if condition="($vo.verify eq 0) "> selected  </if> >待审核</option>
                  <option value="1" <if condition="($vo.verify eq 1) "> selected  </if>>已审核</option>
                  <option value="2" <if condition="($vo.verify eq 2) "> selected  </if>>审核失败</option>
              </select>
          </td>
        </tr>
     </foreach>   
     <?php }else{?>   
     <tr><td>暂无数据</td></tr>
      <?php }?>
      </tbody>
    </table>
    <div>
        {$render}
    </div>
    
         <script type="text/javascript">
   $(".cl_status").change(function(){
        var this_id = $(this).data("id");
        var this_status=$(this).val();
        if ( confirm('你确定操作吗？') ) {
            $.ajax({
                type: "post",
                url: "__ROOT__/index.php/Admin/Requirement/verify",
                dataType: 'json',
                data:{
                    id:this_id,
                    verify:this_status
                },
                success: function(result) {
                    if ( result.flag == 1) {
                        location.reload();
                        //alert('操作成功!');
                    } else{
                        alert('操作失败!');   
                    }
                }
            })
        }else{
            location.reload();
        };
    });
</script>
    
    
    
    
</block>